<?php

namespace app\common\model\mycurrency;

use think\Exception;
use think\Model;
use traits\model\SoftDelete;

class Agent extends Model
{

    //use SoftDelete;

    

    // 表名
    protected $name = 'mycurrency_agent';

    const STATUS_ZHENGCHENG = 1;//代理商状态 = 正常
    const STATUS_JINYONG = 2;//代理商状态 = 禁用

    const IS_IDENTITY_GEREN = 1;//身份 = 个人
    const IS_IDENTITY_QIYE = 2;//身份 = 企业

    //生成代理商唯一编号
    public static function getNumger(){
        $number = date('YmdHis') . mt_rand(1000, 9999);
        $exists = self::where('number', $number)->value('id');
        if (!$exists) {
            return $number;
        }
        return self::getNumger();
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
